﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynaPrecision.FunctionAnalysis
{
	public class ConstantValueFunction<TInput, TResult> : IFunction<TInput, TResult>
		where TResult : struct
	{
		private TResult _constantValue;

		public ConstantValueFunction()
		{
			dynamic temp = 0;
			_constantValue = temp;
		}
		public ConstantValueFunction(TResult _constantValue)
		{
			this._constantValue = _constantValue;
		}

		#region IFunction<TInput,TResult> Members

		public Func<TInput, TResult> Functor
		{
			get
			{
				return x => _constantValue;
			}
		}

		public IFunction<TInput, TResult> Derivative
		{
			get
			{
				return new ConstantValueFunction<TInput, TResult>();
			}
		}

		public IFunction<TInput, TResult> Integral
		{
			get
			{
				dynamic result = new StandardFunction.Polynomial<TResult>();
				result.SetOrder(1, _constantValue);
				return result;
			}
		}

		#endregion
	}
}
